<?php 
class department_Form_FrmDepartment extends Zend_Form
{
	public function frmDepartment($frm = null)
    {
    	$dbBranch = new faculty_Model_DbTable_DbFaculty();
    	$rsBranch =$dbBranch->getAllBranch();
    	$optBranch = array(''=>'ជ្រើសរើស សាខា/Choose Branch');
    	foreach ($rsBranch as $dataBranch){
    		$optBranch[$dataBranch["branch_id"]] = $dataBranch["branch_name"];
    	}
    	$branch = new Zend_Form_Element_Select('branch');
    	$branch->setAttribs(array('class'=>'form-control chzn-select validate[required]','OnChange'=>'getfaculty();'));
    	$branch->setMultiOptions($optBranch);
    	
    	$branch_select = new Zend_Form_Element_Select('branch_select');
    	$branch_select->setAttribs(array('class'=>'form-control' ,'id'=>"box2View", 'multiple'=>"multiple", 'size'=>"8"));
    	
    	$db_fac = new department_Model_DbTable_DbDepartment();
    	$rs_fac = $db_fac->getFaculty();
    	$opt_fac = array(''=>'ជ្រើសរើស សាខា/Choose Branch');
    	foreach ($rs_fac as $row){
    		$opt_fac[$row["faculty_id"]] = $row["faculty_name"];
    	}
    	$faculty = new Zend_Form_Element_Select('faculty');
    	$faculty->setAttribs(array('class'=>'form-control chzn-select validate[required]'));
    	$faculty->setMultiOptions($opt_fac);
    	
    	$department = new Zend_Form_Element_Text("department");
    	$department->setAttribs(array('class'=>'form-control validate[required]'));
    		
    	$status = new Zend_Form_Element_Select('status');
    	$status->setAttribs(array('class'=>'form-control validate[required]'));
    	$opt_status = array(''=>'ជ្រើសរើស ស្ថានភាព','1'=>'ប្រើប្រាស់','0'=>'មិនប្រើប្រាស់');
    	$status->setMultiOptions($opt_status);
    	
    	$description = new Zend_Form_Element_Textarea("description");
    	$description->setAttribs(array('class'=>'form-control'));
    		
    	$id = new Zend_Form_Element_Hidden('id');
    	$this->addElements(array($department,$branch_select,$branch,$status,$faculty,$description,$id));    	
    	if($frm){
    		$id->setValue($frm['department_id']);
    		$department->setValue($frm["department_name"]);
    		$status->setValue($frm["status"]);
    		$description->setValue($frm["description"]);
    		$faculty->setValue($frm["faculty_id"]);
    		$branch->setValue($frm["branch_id"]);
    	}
    	return $this;
     }
}
?>
